<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>文章列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/themes/admin/css/font.css">
    <link rel="stylesheet" href="/themes/admin/css/xadmin.css">
    <link rel="stylesheet" href="/themes/admin/css/common.css">
    <script src="/themes/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/themes/admin/js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">APPID</label>
                            <div class="layui-input-block">
                                <input type="text" name="appid" required  lay-verify="required" value="{$miniApp.value}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">SECRET</label>
                            <div class="layui-input-block">
                                <input type="text" name="secret" required  lay-verify="required" value="{$miniApp.extend}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">首页分享封面</label>
                            <div class="layui-input-inline">
                                <img id="miniapp-cover" style="width: 200px;height: 200px" src="{$cateDetail.cover_image|default='/uploads/default/wx_share_cover.jpg'}">
                            </div>
                            <div class="layui-form-mid layui-word-aux">图片只能为jpg格式</div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button id="btn-submit" class="layui-btn" lay-submit lay-filter="formDemo">修改</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
    //Demo
    layui.use(['form','layer'], function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $.ajax({
                type:"POST",
                data:data.field,
                url:"/admin/miniapp/baseSet",
                success:function (e) {
                    if (e.code == 1){
                        layer.msg(e.msg,{icon:1})
                    }else {
                        layer.msg(e.msg,{icon:2})
                    }
                }
            })
            return false;
        });
    });

    //分类封面上传
    layui.use('upload', function(){
        var upload = layui.upload;
        upload.render({
            elem: '#miniapp-cover'
            ,url: '/admin/miniapp/upload'
            ,auto: false
            ,accept:'images'
            ,field:'Image'
            ,exts:'jpg'
            ,bindAction: '#btn-submit'
            ,choose: function(obj){
                obj.preview(function(index, file, result){
                    $("#miniapp-cover").attr("src",result);
                });
            }
            ,done:function(res){
                if(res.code == 0){
                    layer.msg(res.msg,{icon:2});
                }
            }
        });
    });
</script>
</html>